package com.aggron.common;

import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * 全局异常处理
 * @author    liuhuan on 2018/6/2.
 */
@ControllerAdvice
@Slf4j
public class SpringExcetionResolver  {

    @ExceptionHandler(value = Exception.class)
    @ResponseBody
    public JsonData handle(Exception e){
        log.error(e.getMessage(),e);
        return JsonData.fail(e.getMessage());
    }

}
